﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Configuration;
using BBICMS.Infrastructure.Config;
using System.Web;
using System.Security.Principal;


namespace BBICMS.Infrastructure
{
    public sealed class Helpers
    {
        public static readonly BBICMSSection Settings =
          ((BBICMSSection)WebConfigurationManager.GetSection("bbicmsSetting"));
        
        /// <summary>
        /// 当前用户
        /// </summary>
        public static IPrincipal CurrentUser
        {
            get { return HttpContext.Current.User; }
        }

        /// <summary>
        /// 当前用户名
        /// </summary>
        public static string CurrentUserName
        {
            get
            {
                string userName = string.Empty;
                if (CurrentUser.Identity.IsAuthenticated)
                {
                    userName = CurrentUser.Identity.Name;
                }
                return userName;
            }
        }

        public static string CurrentUserIP
        {
            get { return HttpContext.Current.Request.UserHostAddress; }
        }


    }
    
}
